<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style>
        body {}
    </style>
</head>

<body>
    <header class="aui-bar aui-bar-nav" onclick="handleback()" tapmode>
        <div class="aui-pull-left aui-btn">
            <span class="aui-iconfont aui-icon-left"></span>
        </div>
        <div class="aui-title">质量整改</div>
    </header>
    <div class="aui-tab" id="tabs">
        <div class="aui-tab-item tapmode aui-active" onclick="tabchange(this)" tapmode>需整改</div>
        <div class="aui-tab-item tapmode" onclick="tabchange(this)" tapmode>已整改</div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript">
    var defaultIndex = 0;
    apiready = function() {
        $api.fixStatusBar($api.dom('header'));
        var headerH = $api.offset($api.dom('header')).h;
        var tabH = $api.offset($api.dom('.aui-tab')).h;
        var tab = new auiTab({
          element:document.getElementById("tabs")
        }, function(ret) {
          api.setFrameGroupIndex({
              name: 'matframegroup',
              index: ret.index -1,
              scroll: true,
              reload: true
          });
        })
        var frames = [{
            name: 'matframeone',
            scrollEnabled: false,
            url: './tabs/matframeone.html',
            bgColor: 'rgba(0,0,0,.3)'
        }, {
            name: 'matframetwo',
            scrollEnabled: false,
            url: './tabs/matframetwo.html',
            bgColor: 'rgba(0,0,0,.3)'
        }]
        api.openFrameGroup({
            name: 'matframegroup',
            background: '#fff',
            scrollEnabled: true,
            rect: {
                x: 0,
                y: headerH + tabH,
                w: 'auto',
                h: api.frameHeight - headerH - tabH
            },
            index: 0,
            frames: frames
        }, function(ret, err) {
          // TODO
          if (ret) {
            api.sendEvent({
                name: 'frameChangeEvent',
                extra: {
                    key1: 'value1',
                }
            });

          }
        });

    };
    // tab切换
    function tabchange(e) {
        var tablist = $api.domAll('.aui-tab .aui-tab-item');
        var activeNode = $api.dom('.aui-tab .aui-active');
        if (activeNode === e) {
          return ;
        }
        for (var i = 0; i < tablist.length; i++) {
          if (e === tablist[i]) {
            defaultIndex = i;
          } else {
            $api.removeCls(tablist[i], 'aui-active');

          }
        }
        $api.addCls(tablist[defaultIndex], 'aui-active');
    }
    // 返回
    function handleback() {
        api.closeWin({
            name: 'material'
        });
    }
</script>

</html>
